<?php require_once 'httpFilter.php'; 'conf.php'; ?>
<?php include("includes/libs.php"); ?>
<html>
<title>Get Rich Through Budgeting</title>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="css/styles.css" />
 <style type="text/css">
	select {
	    -moz-border-radius: 4px;
	    -moz-box-shadow: 1px 1px 5px #cfcfcf inset;
	    border: 1px solid #cfcfcf;
	    vertical-align: middle;
	    background-color: transparent;
	}
	option {
	    background-color: #fef5e6;
	    border-bottom: 1px solid #ebdac0;
	    border-right: 1px solid #d6bb86;
	    border-left: 1px solid #d6bb86;
	}
	option:hover {
	    cursor: pointer;
	}

  </style>

<script type="text/javascript" src="editBudget.js"></script>
<script type="text/javascript" src="js/utils.js"></script>

<!--[if IE]><script language="javascript" type="text/javascript" src="plugins/jqplot/excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="plugins/jqplot/jquery.jqplot.min.js"></script>
<link rel="stylesheet" type="text/css" href="plugins/jqplot/jquery.jqplot.css" />

<script type="text/javascript" src="plugins/jqplot/jqplot.categoryAxisRenderer.min.js"></script>
<script type="text/javascript" src="plugins/jqplot/jqplot.barRenderer.min.js"></script>
<script type="text/javascript" src="plugins/jqplot/jqplot.dateAxisRenderer.min.js"></script>
<script type="text/javascript" src="plugins/jqplot/jqplot.pointLabels.js"></script>

</head>
<body>
<div id="msgDlg"></div>
<div id="confirmDlg"></div>
<div id="chartdiv" style="height:400px;width:300px; display: none;"></div>
<div id="loadingPic" style="display: none; position:absolute; left: 0px; top:0px; height:100%; width: 100%; text-align: center;
	           background-image:url('images/translucent.gif'); z-index: 1000;">
</div>
<div id="changeBudgetItemDiv" style="display: none; font-size: 0.8em;">
	Enter new name: <input id="currentBudgetItemName"></input>
</div>

<input type="hidden" id="budgetId" value="<?=$_GET["budgetId"]?>" />

<?php include("includes/navigation.php"); ?>
<?php require_once "classes.php";
	require_once "services/budgetServices.php";
	require_once "util.php";
	?>

<table id="mytable" cellspacing="0" summary="August 2010 Budget">
	<caption>"Getting Rich Slowly"</caption>
	<?php
	$service = new CommonServices;
	$budgetServices = new BudgetService;
	$util = new Util;
	
	$userId = $_SESSION["userid"];
	
	$budgetId = $_GET["budgetId"];
	if ($budgetId == "current"){
		$budgetId = $service->getCurrentBudgetId($userId);
	}

	
	if (!$budgetServices->isThisMyBudget($budgetId)){
		$budgetId = $service->getCurrentBudgetId($userId);
	}
	
	$startDate = $service->getStartDateForBudget($budgetId);
	$endDate = $service->getEndDateForBudget($budgetId);
	$savingsAccId = $budgetServices->getSavingsAccountId($userId);

	$con = mysql_connect(GlobalConfig::db_host_name,GlobalConfig::db_username,GlobalConfig::db_password);
	if (!$con)
	{
		die('Could not connect: ' . mysql_error());
	}

	mysql_select_db(GlobalConfig::db_name, $con);

	$result = mysql_query("SELECT * FROM budget where id=" . $budgetId);

	while($row = mysql_fetch_array($result))
	{
		$budgetName = $row['month'];
	}


	?>
	<tr>
		<th scope="row" colspan="6" class="spec"><?php echo $budgetName ?> 
		</th>
		
		
	</tr>
	<tr class="carryOverHeader">
		<th scope="col">Carry Over</th>
		<th scope="col">Budget</th>
		<th scope="col">Actual</th>
		<th scope="col" colspan="2">Balance</th>
		<th scope="col"></th>
	</tr>
	<? 
		mysql_select_db(GlobalConfig::db_name, $con);

		/*** CARRY OVER ***/
		$query = "select carryover from budget where id=". $budgetId;
		error_log($query);
		$result = mysql_query($query);
		while($row = mysql_fetch_array($result)){
			$carryover = $row["carryover"];
		}
	?>
	<th scope="row" class="spec">Carry Over from Prev. Month</th>
		<td class="spec">R <input type="text" value="<?= $carryover ?>" disabled/></td>
		<td class="spec">R <input id="carryOver" type="text" value="<?= $carryover ?>"/></td>
		<td class="spec" colspan="2">&nbsp;</td>
		<th class="spec">&nbsp;</th>
	<tr>
		<th colspan="6" class="nobg">&nbsp;</th>
	</tr>
	
	<tr class="incomeHeader">
		<th scope="col">Income</th>
		<th scope="col">Budget</th>
		<th scope="col">Actual</th>
		<th scope="col" colspan="2">Balance</th>
		<th scope="col"><a href="#" onclick="createNewItem(1); return false;"><img src="images/new.png" title="Create new row in this category"
			alt="Create new row in this category" border="0" width="15" /></a></th>
	</tr>
	<?php
	/**** INCOME  *****/

	mysql_select_db(GlobalConfig::db_name, $con);
	
	$result = mysql_query("SELECT b.budgetAmount, b.actualAmount, i.id, i.description FROM budget_budgetitem b, budgetitem i where b.budgetid=". $budgetId ." and i.id=b.budgetitemid and categoryId=1");

	$budgetIncome = 0;
	$actualIncome = 0;

	while($row = mysql_fetch_array($result))
	{
		$query = "select SUM(amount) as sum from transaction where budgetitemid=". $row['id'] ." and date(date) >= '". $startDate ."' and date(date) <= '". $endDate ."' and accountId<>".$savingsAccId;
		error_log($query);
		$result1 = mysql_query($query);
		$sum = mysql_fetch_array($result1);

		$budgetAmount = $row['budgetAmount'];
		$actualAmount = $row['actualAmount'];
			
		$budgetIncome = $budgetIncome + $budgetAmount;
		$actualIncome = $actualIncome + $actualAmount;
		?>
	<tr id="<?= $row['id']?>" class="incomeRow">
		<th scope="row" class="spec" name="incomeDescription"><a id="<?= $row['id']?>" href="#" onclick="getBudgetItemTransactions(this); return false;"><?php echo $row['description'] ?></a></th>
		<td class="spec">R <input name="incomeBudget" type="text" value="<?php echo $budgetAmount ?>"></input></td>
		<td class="spec">R <input name="incomeActual" type="text" value="<?=$sum["sum"]?>" disabled></input></td>
		<td class="spec" colspan="2">&nbsp;</td>
		<th class="spec"><a href="#" onclick="deleteItem(this); return false;"><img src="images/delete.png" title="Delete this row" alt="Delete this row"
			border="0" width="10" /></a></th>
	</tr>
	<?php
	}
	?>
	<tr>
		<th scope="row" class="nobg"">&nbsp;</th>
		<td class="total" id="budgetIncomeTotal">R <?php echo $budgetIncome ?></td>
		<td class="total" id="actualIncomeTotal">R <?php echo $actualIncome ?></td>
		<td class="total" colspan="2">&nbsp;</td>
		<td class="total">&nbsp;</td>
	</tr>

	<tr>
		<th colspan="6" class="nobg">&nbsp;</th>
	</tr>

	<tr class="variableHeader">
		<th scope="col">Monthly Variable Expenses</th>
		<th scope="col">Budget</th>
		<th scope="col">Actual</th>
		<th scope="col">Balance</th>
		<th scope="col" width="5%">Status</th>
		<th scope="col"><a href="#" onclick="createNewItem(2); return false;"><img src="images/new.png" title="Create new row in this category"
			alt="Create new row in this category" border="0" width="15" /></a></th>
	</tr>
	<?php
	/**** Monthly Variable Expenses  *****/

	mysql_select_db(GlobalConfig::db_name, $con);

	$result = mysql_query("SELECT b.budgetAmount, b.actualAmount, i.id, i.description FROM budget_budgetitem b, budgetitem i where b.budgetid=". $budgetId ." and i.id=b.budgetitemid and categoryId=2");

	$budgetVariableExpenses = 0;
	$actualVariableExpenses = 0;


	while($row = mysql_fetch_array($result))
	{
		$result1 = mysql_query("select SUM(amount) as sum from transaction where budgetitemid=". $row['id'] ." and date(date) >= '". $startDate ."' and date(date) <= '". $endDate ."' and accountId<>".$savingsAccId);
		$sum = mysql_fetch_array($result1);

		$budgetAmount = $row['budgetAmount'];
		$actualAmount = $row['actualAmount'];
			
		$budgetVariableExpenses = $budgetVariableExpenses + $budgetAmount;
		$actualVariableExpenses = $actualVariableExpenses + $actualAmount;
		?>
	<tr id="<?= $row['id']?>" class="variableRow">
		<th scope="row" class="spec" name="variableDescription"><a id="<?= $row['id']?>" href="#" onclick="getBudgetItemTransactions(this); return false;"><?php echo $row['description'] ?></a></th>
		<td class="spec">R <input name="variableBudgetAmt" type="text" value="<?php echo $budgetAmount ?>"></input></td>
		<td class="spec">R <input name="variableActualAmt" type="text" value="<?php echo $sum["sum"] * -1 ?>" disabled></input></td>
		<td class="spec">R <label name="variableDifferenceAmt"><?php echo ($budgetAmount - $actualAmount) ?></label></td>
		<td class="variableStatus" align="center"><?php echo $util->getPercentage(($sum["sum"] * -1), $budgetAmount) ?></td>
		<th class="spec"><a href="#" onclick="deleteItem(this); return false;"><img src="images/delete.png" title="Delete this row" alt="Delete this row"
			border="0" width="10" /></a></th>
	</tr>

	<?php
	}
	$differenceVariableExpenses = ( $budgetVariableExpenses - $actualVariableExpenses);
	?>
	<tr>
		<th scope="row" class="nobg">&nbsp;</th>
		<td class="total" id="variableBudgetTotal">R <?php echo $budgetVariableExpenses ?></td>
		<td class="total" id="variableActualTotal">R <?php echo $actualVariableExpenses ?></td>
		<td class="total" id="variableDifferenceTotal">R <?php echo $differenceVariableExpenses ?></td>
		<td class="total">&nbsp;</td>
		<td class="total">&nbsp;</td>
	</tr>
	<tr>
		<th colspan="4" class="nobg">&nbsp;</th>
	</tr>
	<tr class="fixedHeader">
		<th scope="col">Monthly Fixed Expenses</th>
		<th scope="col">Budget</th>
		<th scope="col">Actual</th>
		<th scope="col">Balance</th>
		<th scope="col">Status</th>
		<th scope="col"><a href="#" onclick="createNewItem(3); return false;"><img src="images/new.png" title="Create new row in this category"
			alt="Create new row in this category" border="0" width="15" /></a></th>
	</tr>
	<?php
	/**** Monthly Fixed Expenses  *****/

	mysql_select_db(GlobalConfig::db_name, $con);

	$result = mysql_query("SELECT b.budgetAmount, b.actualAmount, i.id, i.description FROM budget_budgetitem b, budgetitem i where b.budgetid=". $budgetId ." and i.id=b.budgetitemid and categoryId=3");

	$budgetFixedExpenses = 0;
	$actualFixedExpenses = 0;

	while($row = mysql_fetch_array($result))
	{
		$result1 = mysql_query("select SUM(amount) as sum from transaction where budgetitemid=". $row['id'] ." and date(date) >= '". $startDate ."' and date(date) <= '". $endDate ."' and accountId<>".$savingsAccId);
		$sum = mysql_fetch_array($result1);
		$budgetAmount = $row['budgetAmount'];
		$actualAmount = $row['actualAmount'];
			
		$budgetFixedExpenses = $budgetFixedExpenses + $budgetAmount;
		$actualFixedExpenses = $actualFixedExpenses + $actualAmount;
		?>

	<tr id="<?= $row['id']?>" class="fixedRow">
		<th scope="row" class="spec" name="fixedDescription"><a id="<?= $row['id']?>" href="#" onclick="getBudgetItemTransactions(this); return false;"><?php echo $row['description'] ?></a></th>
		<td class="spec">R <input name="fixedBudgetAmt" type="text" value="<?php echo $budgetAmount ?>"></input></td>
		<td class="spec">R <input name="fixedActualAmt" type="text" value="<?= $sum["sum"] * -1 ?>" disabled></input></td>
		<td class="spec">R <label name="fixedDifferenceAmt"><?php echo ($budgetAmount - $actualAmount) ?></label></td>
		<td class="fixedStatus"><?php echo $util->getPercentage(($sum["sum"] * -1), $budgetAmount) ?></td>
		<th class="spec"><a href="#" onclick="deleteItem(this); return false;"><img src="images/delete.png" title="Delete this row" alt="Delete this row"
			border="0" width="10" /></a></th>
	</tr>
	<?php
	}
	$differenceFixedExpenses = ($budgetFixedExpenses - $actualFixedExpenses);
	?>
	<tr>
		<th scope="row" class="nobg">&nbsp;</th>
		<td class="total" id="fixedBudgetTotal">R <?php echo $budgetFixedExpenses ?></td>
		<td class="total" id="fixedActualTotal">R <?php echo $actualFixedExpenses ?></td>
		<td class="total" id="fixedDifferenceTotal">R <?php echo $differenceFixedExpenses ?></td>
		<td class="total">&nbsp;</td>
		<td class="total">&nbsp;</td>
	</tr>
	<tr>
		<th colspan="4" class="nobg">&nbsp;</th>
	</tr>
	<tr class="expenseSavingsHeader">
		<th scope="col">Monthly Expenses Savings</th>
		<th scope="col">Budget</th>
		<th scope="col">Actual</th>
		<th scope="col">Balance</th>
		<th scope="col">Status</th>
		<th scope="col"><a href="#" onclick="createNewItem(4); return false;"><img src="images/new.png" title="Create new row in this category"
			alt="Create new row in this category" border="0" width="15" /></a></th>
	</tr>
	<?php
	/**** Monthly Expenses Savings  *****/

	mysql_select_db(GlobalConfig::db_name, $con);

	$result = mysql_query("SELECT b.budgetAmount, b.actualAmount, i.id, i.description FROM budget_budgetitem b, budgetitem i where b.budgetid=". $budgetId ." and i.id=b.budgetitemid and categoryId=4");

	$budgetExpensesSavings = 0;
	$actualExpensesSavings = 0;

	while($row = mysql_fetch_array($result))
	{
		$budgetAmount = $row['budgetAmount'];
		$actualAmount = $row['actualAmount'];
			
		$budgetExpensesSavings = $budgetExpensesSavings + $budgetAmount;
		$actualExpensesSavings = $actualExpensesSavings + $actualAmount;
		?>
	<tr id="<?= $row['id']?>" class="expenseSavingsRow">
		<th scope="row" class="spec"><a id="<?= $row['id']?>" href="#" onclick="getBudgetItemTransactions(this); return false;" name="expenseSavingsDescription"><?php echo $row['description'] ?></a></th>
		<td class="spec">R <input name="expensesSavingsBudgetAmt" type="text" value="<?php echo $budgetAmount ?>"></input></td>
		<td class="spec">R <input name="expensesSavingsActualAmt" type="text" value="<?= $actualAmount ?>"></input></td>
		<td class="spec">R <label name="expensesSavingsDifferenceAmt"><?php echo ($budgetAmount - $actualAmount) ?></label></td>
		<td class="fixedStatus"><?php echo $util->getPercentage($actualAmount, $budgetAmount) ?></td>
		<th class="spec"><a href="#" onclick="deleteItem(this); return false;"><img src="images/delete.png" title="Delete this row" alt="Delete this row"
			border="0" width="10" /></a></th>
	</tr>
	<?php
	}
	$differenceExpensesSavings = ($budgetExpensesSavings - $actualExpensesSavings);
	?>

	<tr>
		<th scope="row" class="nobg">&nbsp;</th>
		<td class="total" id="expensesSavingsBudgetTotal">R <?php echo $budgetExpensesSavings ?></td>
		<td class="total" id="expensesSavingsActualTotal">R <?php echo $actualExpensesSavings ?></td>
		<td class="total" id="expensesSavingsDifferenceTotal">R <?php echo $differenceExpensesSavings ?></td>
		<td class="total">&nbsp;</td>
		<td class="total"><a href="#" onclick="registerSavings(); return false;"><img src="images/synchronize.png" title="Register savings into sub account"
			alt="Register savings into sub account" border="0" width="15" /></a></td>
	</tr>
	<tr>
		<th colspan="4" class="nobg">&nbsp;</th>
	</tr>
	<tr class="savingHeader">
		<th scope="col">Savings</th>
		<th scope="col">Budget</th>
		<th scope="col">Actual</th>
		<th scope="col">Balance</th>
		<th scope="col">Status</th>
		<th scope="col"><a href="#" onclick="createNewItem(5); return false;"><img src="images/new.png" title="Create new row in this category"
			alt="Create new row in this category" border="0" width="15" /></a></th>
	</tr>
	<?php
	/**** SAVINGS  *****/

	mysql_select_db(GlobalConfig::db_name, $con);

	$result = mysql_query("SELECT b.budgetAmount, b.actualAmount, i.id, i.description FROM budget_budgetitem b, budgetitem i where b.budgetid=". $budgetId ." and i.id=b.budgetitemid and categoryId=5");

	$budgetSavings = 0;
	$actualSavings = 0;

	while($row = mysql_fetch_array($result))
	{

		$budgetAmount = $row['budgetAmount'];
		$actualAmount = $row['actualAmount'];
			
		$budgetSavings = $budgetSavings + $budgetAmount;
		$actualSavings = $actualSavings + $actualAmount;
		?>
	<tr id="<?= $row['id']?>" class="savingsRow">
		<th scope="row" class="spec" name="savingsDescription"><a id="<?= $row['id']?>" href="#" onclick="getBudgetItemTransactions(this); return false;"><?php echo $row['description'] ?></a></th>
		<td class="spec">R <input name="savingsBudgetAmt" type="text" value="<?php echo $budgetAmount ?>"></input></td>
		<td class="spec">R <input name="savingsActualAmt" type="text" value="<?php echo $actualAmount ?>"></input></td>
		<td class="spec">R <label name="savingsDifferenceAmt"><?php echo ($budgetAmount - $actualAmount) ?></label></td>
		<td class="fixedStatus"><?php echo $util->getPercentage(($sum["sum"] * -1), $budgetAmount) ?></td>
		<th class="spec"><a href="#" onclick="deleteItem(this); return false;"><img src="images/delete.png" title="Delete this row" alt="Delete this row"
			border="0" width="10" /></a></th>
	</tr>
	<?php
	}
	$differenceSavings = ($budgetSavings - $actualSavings);
	?>
	<tr>
		<th scope="row" class="nobg">&nbsp;</th>
		<td class="total" id="savingsBudgetTotal">R <?php echo $budgetSavings ?></td>
		<td class="total" id="savingsActualTotal">R <?php echo $actualSavings ?></td>
		<td class="total" id="savingsDifferenceTotal">R <?php echo $differenceSavings ?></td>
		<td class="total">&nbsp;</td>
		<td class="total">&nbsp;</td>
	</tr>
	<tr>
		<th colspan="4" class="nobg">&nbsp;</th>
	</tr>

	<?php

	/**** TOTAL CALCULATIONS ****/
	$totalBudgetedBudget = ($budgetVariableExpenses + $budgetFixedExpenses + $budgetExpensesSavings + $budgetSavings);
	$totalActualBudget = ($actualVariableExpenses + $actualFixedExpenses + $actualExpensesSavings + $actualSavings);
	$totalDifferenceBudget =  $differenceVariableExpenses + $differenceFixedExpenses + $differenceExpensesSavings + $differenceSavings;
	?>

	<tr>
		<th scope="row" class="nobg">Total Budget</th>
		<td class="total mainTotal" id="totalBudgetedBudget">R <?php echo $totalBudgetedBudget ?></td>
		<td class="total mainTotal" id="totalActualBudget">R <?php echo $totalActualBudget ?></td>
		<td class="total mainTotal" id="totalDifferenceBudget">R <?php echo ($totalBudgetedBudget - $totalActualBudget) ?></td>
		<td class="total">&nbsp;</td>
		<td class="total">&nbsp;</td>
	</tr>
	<tr>
		<th scope="row" class="nobg">Surplus/Deficit</th>
		<td class="total mainTotal" id="totalBudgetSurplus">R <?php echo ($budgetIncome - $totalBudgetedBudget) ?></td>
		<td class="total mainTotal" id="totalActualSurplus">&nbsp;</td>
		<td class="total mainTotal" id="totalRemainingSurplus">R <?php echo ($actualIncome - $totalActualBudget) ?></td>
		<td class="total">&nbsp;</td>
		<td class="total">&nbsp;</td>
	</tr>
	<tr>
		<th class="nobg"></th>
		<th colspan="5" class="specalt" align="center" height="50">
		<button id="calcBtn">Calculate</button>
		<button id="saveButton">Save</button>
		<button id="cancelButton">Cancel</button>
		</button>
		</th>
	</tr>

</table>
<br/>
<br/>

<? 
	$difference = $service->getSavingsDifference($_SESSION["userid"]);
?>
<table width="400" id="savingsRecon" diffVal="<?=$difference?>">
	<tr>
		<td>
			<fieldset><legend>Summary</legend>
				<? 
					if ($difference < 0){
				?>
				<h3>Funds to transfer from savings: R <?= $difference*-1 ?></h3>
				<?} else if ($difference > 0) {?>
				<h3>Funds to transfer to Savings: R <?= $difference ?></h3>
				<? } else {?>
				<h3>Savings & Cheque accounts are current</h3>
				<? }?>
			</fieldset>
		</td>
	</tr>
</table>

	<?php
	mysql_close($con);
	?>
	
	<?php include("includes/footer.php"); ?>
	
	<div id="unreconciledTransactionsDiv" style="display: none; max-height: 500;" class="scrollable">
		<table width="100%">
			<tr>
				<td><img src="/images/info.png" width="25"/></td>
				<td>
					In this budget you have transactions that have not been categorized. You will need to specify their categories to reconcile these.
				</td>
			</tr>
		</table><br/>
		<table width="100%">
			<tr id="unreconciledRow">
				<th scope="col" width="5%">Select</th>
				<th scope="col" width="20%">Date</th>
				<th scope="col">Description</th>
				<th scope="col" width="15%">Amount</th>
			</tr>
		</table>
	</div>
	<input id="transactionId" type="hidden"/>
	<input id="transactionType" type="hidden"/>
	<div id="reconcileTransactionsDiv" style="display: none;">
			<table width="100%" id="infoTable">
				<tr>
					<td><img src="/images/info.png" width="25"/></td>
					<td>
						Select a transaction on the left to reconcile and create new budget items to fit in your budget.
					</td>
				</tr>
			</table>
			<table width="100%" id="reconcileTransactionsTable" style="display: none;">
				<tr>
			 		<th class="specalt" width="40%">Date</th>
			 		<th class="spec" id="dateField"></th>
			 	</tr>
			 	<tr>
			 		<th class="specalt">Description:</th>
			 		<th class="spec"><input class="textInput" size="20" type="text" id="transDescription" style="text-transform: uppercase"/></th>
			 	</tr>
			 	<tr>
			 		<th class="specalt">Bank Reference</th>
			 		<th class="spec" id="bankRefField"></th>
			 	</tr>
			 	<tr>
			 		<th class="specalt">Auto Reconcile</th>
			 		<th class="spec">
			 			<input id="autoReconcileCB" type="checkbox" onchange="disableAutoRecon();"/>
						<input id="transDescriptor" type="text" class="longTextInput" width="40" disabled value=""/>
					</th>
			 	</tr>
			 	<tr id="transactionTypesRow">
			 		<th class="specalt">Transaction Category</th>
			 		<th class="spec">
						<select id="catSel" onchange="updateBudgetItemsForTranType();">
						<option id="varExpenses" value="budgetCategory2">Variable Expenses</option>
						<option id="fixedExpenses" value="budgetCategory3">Fixed Expenses</option>
						<option id="savingsExpenses" value="budgetCategory4">Savings Expenses</option>
						<option id="income" value="budgetCategory1">Income</option>
						<option id="transfer" value="budgetCategory6">Transfer</option>
					</select>
					</th>
			 	</tr>
			 	<tr id="currentBudgetItemRow">
			 		<th class="specalt">Budget Item</th>
			 		<th class="spec">
						<select id="budgetCategory2" onchange="updateDescription(this);"></select>
						<select id="budgetCategory3" onchange="updateDescription(this);"></select>
						<select id="budgetCategory4" onchange="updateDescription(this);"></select>
						<select id="budgetCategory1" onchange="updateDescription(this);"></select>
						<select id="budgetCategory6" onchange="updateDescription(this);"></select>
						&nbsp;&nbsp;&nbsp;&nbsp; <a href="#" title="Create new budget item" onclick="$('#currentBudgetItemRow').toggle(); $('#newBudgetItemRow').toggle(); $('#newBudgetItem').val('');"><img src="/images/new1.png" border="0" width="20"></img></a>
					</th>
			 	</tr>
			 	<tr id="newBudgetItemRow" style="display: none;">
			 		<th class="specalt">New Budget Item</th>
			 		<th class="spec">
						<input type="text" id="newBudgetItem" style="text-transform: uppercase"/>
						&nbsp;&nbsp;<a href="#" title="Cancel new category" onclick="$('#newBudgetItemRow').toggle(); $('#currentBudgetItemRow').toggle();"><img src="/images/delete.png" border="0" width="17"></img></a>
					</th>
			 	</tr>
			 	<tr>
			 		<th class="specalt">Amount</th>
			 		<th class="spec" id="amountField"></th>
			 	</tr>
			</table>
	</div>
	
	<div id="budgetItemTransactionsDiv" style="display: none;">
		<table  width="100%" cellpadding="0" cellspacing="0">
			<tr id="budgetItemTransHeaderRow">
				<th>date</th>
				<th>description</th>
				<th>Bank Ref.</th>
				<th>Amount</th>
			</tr>
			<tr>
				<th scope="row" class="nobg" colspan="3">&nbsp;</th>
				<td class="total" id="total"></td>
			</tr>
		</table>
	</div>


</body>
</html>
